package com.xx.rpc.core.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常工具类
 *
 * @author hanxiyue
 */
public class ThrowableUtil {

    /**
     * 将异常转化为String
     * <p>
     * Throwable为异常的根类
     *
     * @param e 异常
     * @return String类型的异常
     */
    public static String toString(Throwable e) {
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        return stringWriter.toString();
    }
}
